<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">
<head>
<title>登录界面</title>
<link rel="stylesheet" type="text/css" th:href="@{~/css/reset.css}" />
<link rel="stylesheet" type="text/css" th:href="@{~/css/common.css}" />
<link rel="stylesheet" type="text/css"
	th:href="@{~/thirdlib/font-awesome/css/font-awesome.min.css}" />
</head>
<body>
	<div class="wrap login_wrap">
		<div class="content">
			<div class="logo"></div>
			<div class="login_box">

				<div class="login_form">
					<div class="login_title">登录</div>
					<div class="form_text_ipt">
						<input name="username" type="text" placeholder="手机号/邮箱"
							value="admin"></input>
					</div>
					<div class="ececk_warning">
						<span>手机号/邮箱不能为空</span>
					</div>
					<div class="_warning">
						<span th:text="${msgutext}"></span>
					</div>
					<div class="form_text_ipt">
						<input name="password" type="password" placeholder="密码"></input>
					</div>
					<div class="ececk_warning">
						<span>密码不能为空</span>
					</div>
					<div class="form_text_ipt">
						<!-- onkeydown="keyDown()" -->
						<input style="width: 150px;" name="imageCode" type="text"
							id="imageCode" placeholder="验证码"></input> <img
							th:src="@{~/code/image}"
							onclick="javascript:this.src='/code/image?random='+Math.random()" />
					</div>
					<div class="ececk_warning">
						<span>验证码不能为空</span>
					</div>
					<div class="_warning">
						<span id="span_msg"></span>
					</div>
					<div class="form_check_ipt">
						<div class="left check_left">
							<label><input name="remember-me" type="checkbox" />>下次自动登录</label>
						</div>
						<div class="right check_right">
							<a href="#">忘记密码</a>
						</div>
					</div>
					<div class="form_btn">
						<button id="login">登录</button>
					</div>
					<div class="form_reg_btn">
						<span>还没有帐号？</span><a>未开放注册</a>
						<!-- <a th:href="@{~/register}">马上注册</a> -->
					</div>
					<div class="other_login">
						<div class="left other_left">
							<span>其它登录方式</span>&nbsp;&nbsp;<a th:href="@{~/login/mobilePage}">短信登录</a>
						</div>
						<div class="right other_right">
							<a th:href="@{~/authentication/qq}"><i class="fa fa-qq fa-2x"></i></a>
							<a th:href="@{~/authentication/weixin}"><i
								class="fa fa-weixin fa-2x"></i></a> <a
								th:href="@{~/authentication/weibo}"><i
								class="fa fa-weibo fa-2x"></i></a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script th:src="@{~/thirdlib/jquery/jquery.min.js}"></script>
	<script>
		$(function() {
			$("#login").click(
					function() {
						//判断是否勾选记住我
						var isCheck = $("input[name='remember-me']").is(
								":checked");
						$.ajax({
							url : "/authentication/form",
							type : "POST",
							async : true,
							data : {
								"username" : $("input[name='username']").val(),
								"password" : $("input[name='password']").val(),
								"imageCode" : $("input[name='imageCode']")
										.val(),
								"remember-me" : isCheck
							},
							dataType : "json",
							contentType : "application/x-www-form-urlencoded",
							success : function(data) {
								if (data.rspCode === '103'
										|| data.rspCode === '000100') {
									$("#span_msg").text(data.rspMsg);
								} else {
									window.location.href = "/index";
								}
							},
							error : function(XMLHttpRequest, textStatu,
									errorThrown) {
								alert(XMLHttpRequest.status);
								alert(XMLHttpRequest.readyState);
								alert(textStatus); // paser error;
							}
						});
					});
			
				$('#imageCode').bind('keyup', function(event) {
				　　if (event.keyCode == "13") {
				　　		//回车执行查询
				　　		event.returnValue = false;
						event.cancel = true;
						$("#login").click();
				　　}
				});
		});
	</script>
</body>
</html>